< previous page page_420 next page >

Page 420
Listing 11.4. continued
Private Sub cmdLoadData_Click()
    '
    ' load tabbed data from a file
    '
    Dim strRdLine As String
    Dim strData As String
    Dim strFileName As String
    Dim intFileHandle As Integer
    '
    ' load tab-delimited text file
    strFileName = App.Path & "\..\..\data\graphs\tabdata.txt"
    intFileHandle = FreeFile
    '
    Open strFileName For Input As intFileHandle
        Do While Not EOF(intFileHandle)
            Line Input #1, strRdLine
            strData = strData & strRdLine & vbCrLf
        Loop
    Close #intFileHandle
    '
    ' setup and display graph
    Graph1.GraphType = gphLine
    Graph1.DataReset = gphAllData
    Graph1.QuickData = strData
    '
    Graph1.DrawMode = gphDraw
    '
End Sub
When you save and run the project, press the Load Data button. Your screen should look something like the one in Figure 11.7.
Notice that the only difference between the code in Listing 11.3 and Listing 11.4 is that the strData variable is loaded from the disk file in Listing 11.4.
Adding Titles, Labels, and Legends
In addition to loading data and setting the graph type, you can also set graph titles, labels for the data points, and legends for the graph.
Now add another button to the project to illustrate these features of the graph control. Set the button's Name property to cmdTitles and its Caption property to &Titles. Add Listing 11.5 to the cmdTitles_Click event window.

 
< previous page page_420 next page >

If you like this book, buy it!